package com.sloan.community.util;

import org.springframework.util.StringUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class DateUtils {

    private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm");

    public static LocalDateTime transfer(String time) {
        if (!StringUtils.hasText(time)) {
            return null;
        }

        if (time.length() > 18) {
            time = time.substring(0, 16);
        }
        return LocalDateTime.parse(time, formatter);
    }
}
